#pragma once

#include "rclcpp/rclcpp.hpp"
#include <std_msgs/msg/float64_multi_array.hpp>
#include <iomanip>   // 用于std::setprecision
#include <algorithm> // 用于std::clamp（如果编译器支持）

using namespace std;
using namespace rclcpp;
using namespace std::chrono_literals;

template <typename T>
constexpr const T &clamp(const T &value, const T &lower, const T &upper)
{
    return value < lower ? lower : (value > upper ? upper : value);
}

class plot
{
private:
    rclcpp::Node::SharedPtr node_; // ROS节点指针
    TimerBase::SharedPtr Timer_01;
    rclcpp::Publisher<std_msgs::msg::Float64MultiArray>::SharedPtr array_pub_;

    std::vector<double> array_value_ = {1.0, 2.5, 3.7, 4.2, 5.9};

    void Timer_Callback_01();

public:
    plot(rclcpp::Node::SharedPtr node);
    void publishDoubleArray(const std::vector<double> &data);
};
